//
//  IMTCANMessageFactory.h
//  ROCOMO
//
//  Created by Kyle Sun on 5/17/16.
//  Copyright © 2016 ROCOMO. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "IMTCANMessage.h"
#import "CarModel.h"

@interface IMTCANMessageFactory : NSObject

+ (IMTCANMessage *)confirmMessage;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid u32Params:(IMTU32Params)params;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid s32Params:(IMTS32Params)params;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid p2S32Params:(IMTP2S32Params)params;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid controlParams:(IMTControlParams)params;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid comboParams:(IMTComboParams)params;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid type:(IMTCarControlType)type;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid boolNum:(BOOL)boolean;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid u32Param:(uint32_t)param;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid u64Param:(uint64_t)param;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid u32Param:(uint32_t)param forceExtended:(BOOL)force;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid data:(NSData *)data;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid data:(NSData *)data forceExtended:(BOOL)force;

+ (IMTCANMessage *)messageWithId:(u_int32_t)cid bytes:(Byte *)bytes length:(NSInteger)length shouldFree:(BOOL)shouldFree;

#pragma mark - =======R0的消息=========

+ (IMTCANMessage *)r0_messageWithId:(u_int32_t)cid
                             length:(u_int8_t)length
                             isRead:(BOOL)isRead;

+ (IMTCANMessage *)r0_messageShortWithId:(u_int32_t)cid
                                    data:(unsigned char *)writeData
                                  length:(u_int8_t)length;


+ (IMTCANMessage *)r0_messageDataNumWithId:(u_int32_t)cid
                                    data:(int)writeDataNum
                                  length:(u_int8_t)length;

+ (IMTCANMessage *)r0_messageIAPDataNumWithId:(u_int32_t)cid
                                      data:(int)writeDataNum
                                       length:(u_int8_t)length toDevice:(BOOL)isble;


/*
 * msgType 1 IAP准备；2 开始写入IAP数据；3 数据校验；4 IAP完成指令
 */
+ (IMTCANMessage *)r0_messageIAPDataWithId:(u_int32_t)cid
                                      data:(NSData *)writeData
                                  msgType:(uint8_t)msgType
                                    length:(u_int8_t)length toDevice:(BOOL)isble;

/**
 R0故障检测
 */
+ (IMTCANMessage *)R0_messageDetectionWithId:(u_int32_t)cid
                                        data:(int)writeDataNum
                                      length:(u_int8_t)length;

+ (Byte *)dataWithInt:(int)num andLength:(int)length;

/// r0故障检测
+(IMTCANMessage *)R0_DetectionMessageWithIndex:(u_int32_t)index length:(u_int32_t)length ;

@end

